#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>

//int main()
//{
//	char c;
//	int v0 = 0, v1 = 0, v2 = 0;
//		do
//		{
//			switch (c = getchar())
//			{
//			case'a':case'A':
//			case'e':case'E':
//			case'i':case'I':
//			case'o':case'O':
//			case'u':case'U':v1 += 1;
//			default:v0 += 1; v2 += 1;
//			}
//		} while (c != '\n');
//		printf("v0=%d,v1=%d,v2=%d\n", v0, v1, v2);
//		return 0;
//}


int main()
{
	int n = 0;
	
	while (scanf_s("%d", &n))
	{
		for (int i = 0; i < n; i++)
		{
			int lower = 0;
			int higher = 0;
			int digit = 0;
			int other = 0;
			char arr[101] = { 0 };
			scanf_s("%s", &arr);
			if (strlen(arr) < 8)
			{
				printf("NO\n");
				continue;
			}
			if (arr[0] >= '0' && arr[0] <= '9')
			{
				printf("NO\n");
				continue;
			}
			for (int i = 0; arr[i] != '\0'; i++)
			{
				if (arr[i] >= '0' && arr[i] <= '9')
					digit++;
				else if (arr[i] >= 'a' && arr[i] <= 'z')
					lower++;
				else if (arr[i] >= 'A' && arr[i] <= 'Z')
					higher++;
				else
					other++;
			}
			if (other != 0)
			{
				printf("NO\n");
				continue;
			}
			if ((lower > 0) + (digit > 0) + (higher > 0) < 2)
			{
				printf("NO\n");
				continue;
			}
			printf("Yes\n");
		}
	}
	return 0;
} 


